/**
 * @program: FindFileDemo
 * @author: Ding Houwen
 * @create: 2019-08-01 13:06
 **/

package com.example.findfiledemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    private String basePackage = "com.example.findfiledemo.controller";

    private String title = "智能问答 Demo API";

    private String version = "V1.0";

    private String description = "对用户的问题进行智能问答 并 对文件名进行搜索；对word、Excel、pdf文件中关键字的搜索；对中文、英文的关键字搜索 ";

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(basePackage))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //页面标题
                .title(title)
                //版本号
                .version(version)
                //描述
                .description(description)
                .build();
    }
}
